import subprocess

# 运行带有管道的命令
output = subprocess.check_output("ls -l | grep 'txt'", shell=True, text=True)

print("命令输出：")
print(output)